package com.xja.gittest.service.impl;

import com.xja.gittest.entity.Student;
import com.xja.gittest.mapper.StudentMapper;
import com.xja.gittest.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public void delStudentById(Integer stuId) {
        studentMapper.deleteByPrimaryKey(stuId);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public Student selectStudentById(Integer stuId) {
        return studentMapper.selectByPrimaryKey(stuId);
    }
    @Override
    public void insertSelective(Student student){
        studentMapper.insertSelective(student);
    }

    @Override
    public void deleteByPrimaryKey(Integer stuId) {
         studentMapper.deleteByPrimaryKey(stuId);
    }

    @Override
    public List<Student> selectAll(){
        return studentMapper.selectAll();
    }

    @Override
    public void updateByPrimaryKeySelective(Student record) {
        studentMapper.updateByPrimaryKeySelective(record);
    }
}
